<template>
  <div class="c-pt60 c-flex-column c-justify-sa c-h">
    <loading-status-tem :noDataText="noneInfo" :noData="true"></loading-status-tem>
    <!-- <div class="back-index" @click="clickGoIndex">{{from == 'course' || from == 'myExam' || from == 'reservationSection' || from == 'form' ? '返回上一页' : from == 'booking' ? '返回师资列表' : (from == 'vipCollage' ? '返回会员升级' : '返回首页')}}</div> -->
    <div v-if="!isApp" class="c-mh72 c-fs28 c-fc-white theme-bg c-pv16 c-flex-row c-justify-center c-br36 coms-live-mod1-none" @click="clickGoIndex">{{backText}}</div>
  </div>
</template>

<script>
import loadingStatusTem from "@/components/templates/common/loadingStatusTem.vue";
import { utilJs } from "@/utils/common.js"
export default {
  name: "EmptyPage",
  components: {
    loadingStatusTem
  },
  data() {
    return {
      isApp: false,
      noneInfo: "很抱歉，该资源已下架",
      from: '',
      theme: localStorage.getItem("colorName") ? localStorage.getItem("colorName") : 'mb5_default',
      historyLength: 0,
      clockInId:0,
    };
  },
  computed: {
    backText() {
      return (this.from == 'course' || this.from == 'myExam' || this.from == 'reservationSection' || this.from == 'form' || this.from == 'practice' || this.from == 'agent') && this.historyLength > 1
        ? '返回上一页' : this.from == 'clockIn' ? '返回打卡'
        : this.from == 'booking' ? '返回师资列表' : this.from == 'circle' ? '返回圈子列表' : (this.from == 'vipCollage' ? '返回会员升级' : '返回首页')
    }
  },
  created() {
    utilJs.appShare(this);
  },
  activated() {
    if (this.$route.query.info) {
      this.noneInfo = this.$route.query.info;
    }
    this.from = this.$route.query.from;
    this.$store.commit('updateLoadingStatus', {
      isLoading: false
    });
    this.isApp = utilJs.isAndroidApp() || utilJs.isIOSAppALL();
    this.historyLength = window.history.length;
    if (this.from == 'clockIn') {
      this.clockInId = this.$route.query.clockInId
    }
    this.wechatShare();
  },
  methods: {
    clickGoIndex() {
      if (this.$isWxApp()) {
        // 履约小程序得首页是作为tab
        if (sessionStorage.getItem('isKpStudy')) {
          utilJs.miniProgramGoTo('switchTab', "/pages/home/index/index");
          return
        }
        utilJs.miniProgramGoTo('replace', !localStorage.getItem("wxAppVersion") ? "/pages/home/index/index" : "/pages/tabWebview/index");
      } else if (this.from == 'MALL') {
        this.$routerGo(this, "replace", { path: "/" });
      } else if ((this.from == 'course' || this.from == 'myExam' || this.from == 'reservationSection' || this.from == 'form' || this.from == 'practice') && this.historyLength > 1) {
        this.$router.go(-1);
      } else if (this.from == 'vipCollage') {
        this.$routerGo(this, "replace", { path: "/member/vip/vipUp" });
      } else if (this.from == 'booking') {
        this.$routerGo(this, "replace", { path: "/homePage/booking/bookingList" });
      } else if (this.from == 'circle') {
        this.$routerGo(this, "replace", { path: "/homePage/circle/circleList" });
      } else if (this.from == 'clockIn') {
        this.$routerGo(this, "replace", {
          path: "/homePage/clockIn/clockInDetail",
          query: {
            clockInId:this.clockInId
          }
        });
      } else {
        this.$routerGo(this, "replace", { path: "/" });
      }
    },
    //分享
    wechatShare: function () {
      utilJs.wechatConfig("", "", "", "", function () { });
    },
    //手机端分享
    appShare: function () {
      utilJs.appShareTrue("", "", "", "");
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.back-index {
  padding: 0.5rem 0;
  border-radius: 20px;
  background: #66cc33;
  font-size: 0.7rem;
  width: 5rem;
  text-align: center;
  color: #fff;
  margin: 2rem auto;
}
</style>
